# -*- coding: utf-8 -*-
from south.utils import datetime_utils as datetime
from south.db import db
from south.v2 import SchemaMigration
from django.db import models


class Migration(SchemaMigration):

    def forwards(self, orm):
        # Removing unique constraint on 'Banco', fields ['numero']
        db.delete_unique(u'core_banco', ['numero'])

        # Adding model 'Sucursal'
        db.create_table(u'core_sucursal', (
            (u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
            ('numero', self.gf('django.db.models.fields.CharField')(max_length=3)),
            ('banco', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['core.Banco'])),
            ('nombre', self.gf('django.db.models.fields.CharField')(max_length=50)),
            ('alias', self.gf('django.db.models.fields.CharField')(max_length=50)),
            ('codigo_postal', self.gf('django.db.models.fields.CharField')(max_length=4)),
        ))
        db.send_create_signal(u'core', ['Sucursal'])

        # Adding unique constraint on 'Sucursal', fields ['numero', 'banco']
        db.create_unique(u'core_sucursal', ['numero', 'banco_id'])

        # Adding field 'Banco.id'
        db.add_column(u'core_banco', u'id',
                      self.gf('django.db.models.fields.AutoField')(default=datetime.datetime(2014, 3, 19, 0, 0), primary_key=True),
                      keep_default=False)


        # Changing field 'Banco.numero'
        db.alter_column(u'core_banco', 'numero', self.gf('django.db.models.fields.CharField')(max_length=3))

    def backwards(self, orm):
        # Removing unique constraint on 'Sucursal', fields ['numero', 'banco']
        db.delete_unique(u'core_sucursal', ['numero', 'banco_id'])

        # Deleting model 'Sucursal'
        db.delete_table(u'core_sucursal')

        # Deleting field 'Banco.id'
        db.delete_column(u'core_banco', u'id')


        # Changing field 'Banco.numero'
        db.alter_column(u'core_banco', 'numero', self.gf('django.db.models.fields.PositiveSmallIntegerField')(primary_key=True))
        # Adding unique constraint on 'Banco', fields ['numero']
        db.create_unique(u'core_banco', ['numero'])


    models = {
        u'core.banco': {
            'Meta': {'object_name': 'Banco'},
            'alias': ('django.db.models.fields.CharField', [], {'max_length': '50'}),
            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
            'nombre': ('django.db.models.fields.CharField', [], {'max_length': '50'}),
            'numero': ('django.db.models.fields.CharField', [], {'max_length': '3'})
        },
        u'core.sucursal': {
            'Meta': {'unique_together': "(('numero', 'banco'),)", 'object_name': 'Sucursal'},
            'alias': ('django.db.models.fields.CharField', [], {'max_length': '50'}),
            'banco': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['core.Banco']"}),
            'codigo_postal': ('django.db.models.fields.CharField', [], {'max_length': '4'}),
            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
            'nombre': ('django.db.models.fields.CharField', [], {'max_length': '50'}),
            'numero': ('django.db.models.fields.CharField', [], {'max_length': '3'})
        }
    }

    complete_apps = ['core']